package com.mooc.lib_common.model

import android.os.Parcel
import android.os.Parcelable

/**
 * 视频列表UGC实体类
 * */
class UGCEntity() : Parcelable{
    var likeCount = 0
    var shareCount = 0
    var commentCount = 0
    var hasFavorite = false
    var hasLiked = false
    var hasdiss = false
    var hasDissed = false

    constructor(parcel: Parcel) : this() {
        likeCount = parcel.readInt()
        shareCount = parcel.readInt()
        commentCount = parcel.readInt()
        hasFavorite = parcel.readByte() != 0.toByte()
        hasLiked = parcel.readByte() != 0.toByte()
        hasdiss = parcel.readByte() != 0.toByte()
        hasDissed = parcel.readByte() != 0.toByte()
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeInt(likeCount)
        parcel.writeInt(shareCount)
        parcel.writeInt(commentCount)
        parcel.writeByte(if (hasFavorite) 1 else 0)
        parcel.writeByte(if (hasLiked) 1 else 0)
        parcel.writeByte(if (hasdiss) 1 else 0)
        parcel.writeByte(if (hasDissed) 1 else 0)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<UGCEntity> {
        override fun createFromParcel(parcel: Parcel): UGCEntity {
            return UGCEntity(parcel)
        }

        override fun newArray(size: Int): Array<UGCEntity?> {
            return arrayOfNulls(size)
        }
    }
}